feat(vite): add namespace support for multi-build setups#41
Conversation
799a34c to
9be59e9
Compare
There was a problem hiding this comment.
Pull request overview
Adds namespaced Vite build support to Sugar’s Vite integration so multiple independent Vite builds (e.g., app + theme/plugin) can coexist and be referenced from templates via an @name/ prefix.
Changes:
- Introduces
ViteConfigas a per-build configuration value object and threads it throughViteExtension→ViteAssetResolver. - Makes
ViteAssetResolvernamespace-aware (per-namespace manifest caching, dev server URL routing, and@vite/clientinjection tracking). - Adds/updates unit + integration tests and extends Vite docs with namespace usage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/Extension/Vite/ViteExtension.php |
Accepts namespace configs and constructs the resolver using a default ViteConfig plus named namespace configs. |
src/Extension/Vite/ViteConfig.php |
Adds a readonly value object encapsulating per-build Vite settings. |
src/Extension/Vite/Runtime/ViteAssetResolver.php |
Implements namespaced entry parsing, per-namespace manifest caching, and per-namespace dev server/client injection behavior. |
tests/Unit/Extension/Vite/ViteExtensionTest.php |
Verifies namespace configs flow through the extension into the resolver. |
tests/Unit/Extension/Vite/ViteConfigTest.php |
Covers ViteConfig construction and default values. |
tests/Unit/Extension/Vite/Runtime/ViteAssetResolverTest.php |
Adds namespace-specific resolver behavior tests and refactors test setup via a helper. |
tests/Integration/ViteIntegrationTest.php |
Exercises namespaced dev/prod rendering through the full engine pipeline. |
docs/content/extensions/vite.dj |
Documents the new namespace configuration and template syntax. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Adds namespace support to
ViteExtension, allowing multiple independent Vite builds (e.g. a plugin or theme) to coexist in a single Sugar application.What changed
New:
ViteConfigvalue objectA new
ViteConfigreadonly class consolidates all per-build configuration:assetBaseUrl,manifestPath,devServerUrl,injectClient, anddefaultEntry. It is used both for the default (root) context and for named namespaces, keeping resolver internals DRY.ViteExtension— new$namespacesparameterTemplate syntax
Namespace entries use an
@name/prefix, consistent with Sugar's existing template namespace convention:ViteAssetResolver— fully namespace-awarearray<string, array>keyed by namespace)@vite/clientinjection trackingdevServerUrlfalls back to the root config when omitted from a namespaceViteConfigTests
ViteAssetResolverTestcovering: dev server routing per namespace, root server fallback, independent manifest loading, unknown namespace error, per-namespace client injection, entry deduplication, anddefaultEntryusageViteExtensionTestverifying namespace configs flow through to the resolverViteConfigTestfor the value objectViteIntegrationTestcovering multi-build dev/prod rendering and mixed-namespace entry listsBackward compatibility
Fully backward-compatible. The
$namespacesparameter defaults to[]and all existing flat constructor parameters onViteExtensionare unchanged.